package com.huan.util;

import job.RenameFile;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class GetResourcesFile {
    public static BufferedReader getReader(String fileName){
        // 获取ClassLoader
        ClassLoader classLoader = RenameFile.class.getClassLoader();

        // 读取resources下的文件
        InputStream inputStream = classLoader.getResourceAsStream(fileName);

        if (inputStream == null) {
            throw new IllegalArgumentException("文件未找到!");
        } else {
            BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
            return reader;
        }
    }
}
